package com.area.cth.mapper;

import com.area.cth.pojo.Manage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ManageMapper {
    @Insert("insert into manage(launch_user,receive_user,goods_id,launch_price,state,create_time,update_time)" +
            " values(#{launchUser},#{receiveUser},#{goodsId},#{launchPrice},#{state},#{createTime},#{updateTime})")
    void addManage(Manage m);

    List<Manage> getReceiveManage(Integer uid);

    List<Manage> getLaunchManage(Integer uid);

    @Update("update manage set state=#{manageState},update_time=now() where id=#{mId}")
    void updateState(String manageState, Integer mId);

    @Delete("delete from manage where id=#{mId}")
    void deleteManage(Integer mId);

    @Select("select count(1) from manage where goods_id=#{gId} and state='已同意'")
    Integer agreeCount(Integer gId);

    @Select("select * from manage where id=#{mId}")
    Manage selectUsersByManageId(Integer mId);
}
